<?php
/**
 * @file
 * Clears twitter sessions and redirects to the signin page.
 */

		//for signout
		// clearnup
		//clearnup twitter session/cookie
		if (!(empty($_SESSION['access_token'])))
		{
			session_start();
			require_once('JSON/JSON.php');
			require_once('twitteroauth/twitteroauth.php');
			require_once('config.php');
			
			$access_token = $_SESSION['access_token'];
			/* Create a TwitterOauth object with consumer/user tokens. */
			$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']);
			// account/end_session
			$method = 'account/end_session';
			$response = $connection->POST($method);
		}
	    //clearnup session
		unset($_SESSION['twitter_logged']);
		unset($_SESSION['twitter_name']);
		unset($_SESSION['twitter_logged_image']);
		unset($_SESSION['twitter_id']);
  
		unset($_SESSION['oauth_token']);
		unset($_SESSION['oauth_token_secret']);
		unset($_SESSION['access_token']);

		/* Redirect to page with the connect to Twitter option. */
		header('Location: ./signin.php?force');

